// import Fetch from '@/api/base';
import axios from "@/api/axios";
//  axios.defaults.baseURL = process.env.NODE_ENV === 'production' ?  'http://zcs.jdcloud.com:8089' : ""
const prodBaseUrl = "https://zc.ggj.gov.cn/api/cityos/form-template/";
const testBaseUrl = "http://116.198.40.249/api/cityos/form-template/";
const buildBaseUrl = process.env.BUILD_ENV === "prod" ? prodBaseUrl : testBaseUrl;
axios.defaults.baseURL = process.env.NODE_ENV === "production" ? prodBaseUrl : "";

// 新建项目
export const saveProject = (data) => axios.post("/project/save", data);
// 修改项目名称
export const changeName = (data) => axios.post("/project/changeName", data);
// 删除项目
export const deleteProject = (data) => axios.post("/project/delete", data);
// 获取所有项目
export const getAllProjectList = () => axios.post("/project/getAll");
// 获取所有项目和模板
export const getProjectsAndTemplates = () => axios.post("/project/getProjectsAndTemplates");
// 新建模板
export const saveTemplate = (data) => axios.post("/template/save", data);
// 修改模板名称
export const updateName = (data) => axios.post("/template/updateName", data);
// 修改模板内容
export const updateTemplate = (data) => axios.post("/template/saveVersion", data);
// 删除模板
export const deleteTemplate = (data) => axios.post("/template/delete", data);
// 模糊搜索模板
export const searchTemplate = (data) => axios.post("/template/getTemplateByName", data);
// 根据id获取模板详情
export const getTemplateById = (data) => axios.post("/template/getTemplateInfoByTemplateId", data);
// 数据绑定中的数据库列表
export const getDatabases = (data) => axios.post("/template/getDatabases", data);
// 数据表列表
export const getTables = (data) => axios.post("/template/getTables", data);
// 字段列表
export const getFields = (data) => axios.post("/template/getFields", data);
// 查询流程
export const getProcedure = (data) => axios.post("/template/getProcedure", data);
// 更新业务数据模板
export const upsert = (data) => axios.post("/datas/upsert", data);
// 获取业务模板
export const getBusiness = (data) => axios.post("/datas/getBusiness", data);
// 获取用户信息
export const getUserInfo = () => {
    const token = localStorage.getItem("access_token")
        ? JSON.parse(JSON.parse(localStorage.getItem("access_token")).v)
        : "Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyVHlwZSI6MCwiand0VHlwZSI6InVzZXIiLCJ1c2VySWQiOiIxIiwidGVuYW50SWQiOiIxIiwidXNlcm5hbWUiOiJhZG1pbiIsInNlc3Npb25Ub2tlbiI6ImRjYmU1OTdiYjgyMjQxNGU4OTVhMWUxMDU4MWRmZGE3IiwiaXNzIjoiZHJpZ2h0Iiwic3ViIjoiYWNjZXNzVG9rZW4iLCJpYXQiOjE2NjcyNzMyMzMsIm5iZiI6MTY2NzI3MzE3M30.AgMIbHNrdOjhBtTwj3z4KKy-S9Zpzw7bCKxykVzhT4Q";
    return axios({
        method: "GET",
        url: "/user/getUserInfo",
        headers: {
            Authorization: token,
        },
    });
};
